﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta charset="utf-8" />
</head>
<body>
    <audio id="myAudio"></audio>
    <script>
        var myAudio = document.getElementById('myAudio');
        myAudio.preload = true;
        myAudio.autoplay = true;
        myAudio.src = '../content/audio/海阔天空.mp3';
        console.info('当前音量：' + myAudio.volume);
        /**说明，
        *在初始加载时duration 是NaN，
        *当可以播放的时候，就可以获取到当前音频的总长度
        **/
        console.info('总长度：' + myAudio.duration);
        myAudio.onplay = function () {
            console.info("开始播放");
        }
        myAudio.oncanplay = function () {
            console.info('进入可以播放状态');
            console.info('总长度：' + myAudio.duration);
        }
        //加载状态监听
        myAudio.ontimeupdate = function (e) {
            // console.info(myAudio.currentTime);
        }
    </script>
</body>
</html>
